//
//  ZHFRadioListCell.m
//  GoTraveling
//
//  Created by dllo on 15/12/26.
//  Copyright © 2015年 开发华佗. All rights reserved.
//

#import "ZHFRadioListCell.h"

@interface ZHFRadioListCell ()

@property (nonatomic, strong)UIImageView *headImageView;
@property (nonatomic, strong)UILabel *titleLabel;
@property (nonatomic, strong)UILabel *nameLabel;
@property (nonatomic, strong)UILabel *contentLabel;
@property (nonatomic, strong)UIImageView *countImageView;

@end

@implementation ZHFRadioListCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews{
    
    self.headImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.contentView.frame.origin.x + 10 * ADAPT_WIDTH, self.contentView.frame.origin.y + 12.5 * ADAPT_HEIGHT, 85 * ADAPT_WIDTH, 85 * ADAPT_HEIGHT)];
    self.headImageView.backgroundColor = [UIColor greenColor];
    [self.contentView addSubview:self.headImageView];
    
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.headImageView.frame.origin.x + self.headImageView.frame.size.width + 15 * ADAPT_WIDTH, self.headImageView.frame.origin.y + 10 * ADAPT_HEIGHT, 200 * ADAPT_WIDTH, 20 * ADAPT_HEIGHT)];
    [self.titleLabel setTextColor:[UIColor colorWithRed:0.39 green:0.39 blue:0.39 alpha:1]];
    self.titleLabel.font = [UIFont systemFontOfSize:17 * ADAPT_WIDTH];
    [self.contentView addSubview:self.titleLabel];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.titleLabel.frame.origin.x, self.titleLabel.frame.origin.y + self.titleLabel.frame.size.height + 5 * ADAPT_HEIGHT, 100 * ADAPT_WIDTH, 20 * ADAPT_HEIGHT)];
    self.nameLabel.font = [UIFont systemFontOfSize:11 * ADAPT_WIDTH];
    [self.nameLabel setTextColor:[UIColor colorWithRed:0.52 green:0.59 blue:0.67 alpha:1]];
    [self.contentView addSubview:self.nameLabel];
    
    self.contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.nameLabel.frame.origin.x, self.nameLabel.frame.origin.y + self.nameLabel.frame.size.height + 5 * ADAPT_HEIGHT, SCREEN_WIDTH - self.headImageView.frame.size.width - self.headImageView.frame.origin.x, 20 * ADAPT_HEIGHT)];
    self.contentLabel.font = [UIFont systemFontOfSize:11 * ADAPT_WIDTH];
    [self.contentLabel setTextColor:[UIColor grayColor]];
    [self.contentView addSubview:self.contentLabel];
    
    self.countImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.headImageView.frame.origin.x + 280 * ADAPT_WIDTH, self.headImageView.frame.origin.x + 15 * ADAPT_HEIGHT, 30 * ADAPT_WIDTH, 30 * ADAPT_HEIGHT)];
    self.countImageView.image = [UIImage imageNamed:@"iconfont-shengyin.png"];
    [self.contentView addSubview:self.countImageView];
    
    self.countLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.countImageView.frame.origin.x + self.countImageView.frame.size.width + 5 * ADAPT_WIDTH, self.countImageView.frame.origin.y + 5 * ADAPT_HEIGHT, 55 * ADAPT_WIDTH, 20 * ADAPT_HEIGHT)];
    self.countLabel.font = [UIFont systemFontOfSize:10 * ADAPT_WIDTH];
    [self.contentView addSubview:self.countLabel];
    [self.countLabel setTextColor:[UIColor grayColor]];
    
}

- (void)setAllList:(ZHFAllList *)allList
{
    [self.headImageView sd_setImageWithURL:[NSURL URLWithString:allList.coverimg] placeholderImage:[UIImage imageNamed:@"trip_edit_empty_content.png"]];
    self.titleLabel.text = allList.title;
    NSString *str = [NSString stringWithFormat:@"by: %@", [[allList valueForKey:@"userinfo"] valueForKey:@"uname"]];
    self.nameLabel.text = str;
    [self.nameLabel sizeToFit];
    self.contentLabel.text = allList.desc;
    self.countLabel.text = [NSString stringWithFormat:@"%ld",allList.count];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
